import 'package:flutter/cupertino.dart';
import 'package:get/route_manager.dart';
import 'package:sp_util/sp_util.dart';
import 'package:yp/router.dart';

class AuthMiddleware extends GetMiddleware {
  @override
  int priority = 0;

  AuthMiddleware({this.priority});

  @override
  RouteSettings redirect(String route) {
    var token = SpUtil.getString('token');
    return token == null || route == RouteConfig.mallLogin ? null : RouteSettings(name: RouteConfig.mallLogin);
  }
}